
import math
import time
from model.user_model import UserModel


class ConsoleService:
    def __init__(self, id=None, user=None, pwd=None, states=None, switchs_to=None, create_time=None, create_by=None,
                 describe=None):
        self.id = id
        self.user = user
        self.pwd = pwd
        self.states = states
        self.switchs_to = switchs_to
        self.create_time = create_time
        self.create_by = create_by
        self.describe = describe

    def stop_user(self):
        user = UserModel(user=self.user,states=self.states)
        user.update_state_by_user()

    @staticmethod
    def get_work_users():#获取工作中机器人数据
        work_users = UserModel().get_by_states(1)
        return work_users
    @staticmethod
    def get_depth():#获取工作机器人数量，并计算ui页面布局行数，每行布局4个
        qty = UserModel().get_qty_by_states(1)['qty']
        depth = math.ceil(qty/4)
        return depth
    @staticmethod
    def get_qty():
        qty = UserModel().get_qty_by_states(1)['qty']
        return qty


# DD=ConsoleService.get_work_users()
#
# print(DD[0].user)
# print(DD[1])
#

